/*
 * @Author: xiaosihan 
 * @Date: 2024-10-31 02:24:08 
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-10-31 02:50:10
 */

// PDFModel

import { autorun } from "mobx";
import { ReactNode, useEffect, useRef, useState } from "react";
import styles from "./pdfModal.module.less";
import Modal from "antd/es/modal";
import pdfStore from "./pdfStore";
import { isEmpty } from "lodash";

interface Iprops {
    children?: ReactNode
}

// pdf 弹窗
export default function PDFModel() {

    const dom = useRef<HTMLDivElement | null>(null);
    const [pdfUrl, setPdfUrl] = useState(pdfStore.pdfUrl);

    useEffect(() => autorun(() => {
        setPdfUrl(pdfStore.pdfUrl);
    }, { delay: 10 }), []);

    return (
        <Modal
            width={"82vw"}
            open={!isEmpty(pdfUrl)}
            centered={true}
            footer={false}
            onCancel={() => {
                pdfStore.setPdfUrl("");
            }}
            rootClassName={styles.pdfModal}
        >
            <div ref={dom} className={styles.pdfModal} >
                <iframe src={pdfUrl} className="iframe"></iframe>
            </div>
        </Modal>
    );

}